package types

import (
	"todo-list/constants"
)

// Response 基础响应体
type Response struct {
	Status constants.StatusCode `json:"status"`
	Data   any                  `json:"data"`
	Msg    string               `json:"msg"`
	Error  string               `json:"error"`
}

type PagedReq struct {
	Page  int `json:"page" form:"page" uri:"page"`
	Limit int `json:"limit" form:"limit" uri:"limit"`
}

func (req *PagedReq) GetPage() int {
	if req.Page == 0 {
		req.Page = 1
	} else if req.Page == -1 {
		req.Page = 0
	}
	return req.Page
}
func (req *PagedReq) GetLimit() int {
	if req.Limit == 0 {
		req.Limit = 10
	} else if req.Limit == -1 {
		req.Limit = 0
	}
	return req.Limit
}

// PagedData 分页类型data
type PagedData struct {
	Item  any   `json:"item"`
	Total int64 `json:"total"`
}

type DataList []any
